const net = require('net');
require('dotenv').config();

const DOMAIN = process.env.TEMPEMAIL_SMTP_DOMAIN || 'localhost';
const PORT = process.env.TEMPEMAIL_SMTP_PORT || 465;

console.log(`正在测试 SMTP 连接 ${DOMAIN}:${PORT}...`);

const client = new net.Socket();

client.connect(PORT, DOMAIN, () => {
    console.log('连接成功！');
    client.end();
});

client.on('data', (data) => {
    console.log('收到服务器响应:', data.toString());
});

client.on('error', (err) => {
    console.error('连接错误:', err);
});

client.on('close', () => {
    console.log('连接已关闭');
});

// 5秒后超时
setTimeout(() => {
    console.log('连接超时');
    client.destroy();
    process.exit(1);
}, 5000); 